﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using WeiboPlus.Shell.Model;
using WeiboPlus.ViewModel;
using System.Windows.Media.Imaging;

namespace WeiboPlus.Shell.ViewModel
{
    public class CardViewModel : ViewModelBase<Card>
    {
        public const string IMAGE_FOLDER = "/Images/Cards/";

        static BitmapImage backside = new BitmapImage(new Uri(IMAGE_FOLDER + "backside.jpg", UriKind.Relative));

        public CardViewModel()
        {
            PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(CardViewModel_PropertyChanged);
        }

        void CardViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Item")
            {
                Init();
            }
            //throw new NotImplementedException();
        }

        void Init()
        {
            ImageSource = new Uri(Item.Imagesource, UriKind.Relative);
        }

        bool isSelected;

        public bool IsSelected
        {
            get { return isSelected; }
            set
            {
                isSelected = value;
                RaisePropertyChanged("IsSelected");
            }
        }

        Uri imageSource;

        public Uri ImageSource
        {
            get { return imageSource; }
            set { imageSource = value; RaisePropertyChanged("ImageSource"); }
        }

       
        public ImageSource BackImage
        {
            get { return backside; }
        }
    }
}
